package  com.trabajoit.model;
import java.util.ArrayList;
import java.util.List;
import negocio.Instalacion;
import negocio.dao.DAO;
public class InstalacionDespachador{
	public InstalacionDespachador(){}
	public static ArrayList< Instalacion > getInstalacions(){
		DAO us = new DAO();
                List a = new ArrayList();
                ArrayList<Instalacion> u = new ArrayList<Instalacion>();
                try{
                a = us.list("Instalacion");
                }catch(Exception e){
                }
                for(Object o : a){
                    u.add((Instalacion)o);
                }
                return u;
	}
	public static  Instalacion  getInstalacionBeanById(int idinstalacion){
		DAO us = new DAO();
		Instalacion b = null;
		try{
                 b = (Instalacion)us.read("Instalacion", idinstalacion);
                }catch(Exception e){
                    
                }
                return b;
	}
	public static int grabarInstalacion(Instalacion b){
		DAO us = new DAO();
		try{
            us.create(b,"Instalacion");
            return 1;
                }catch(Exception e){
            return 0;
                }
	}
	public static int actualizarInstalacion(Instalacion b){
            DAO us = new DAO();
		try{
            Instalacion u = (Instalacion)us.read("Instalacion", b.getIdInstalacion());
            u.setDescripcion(b.getDescripcion());
            u.setDireccion(b.getDireccion());
            u.setFoto(b.getFoto());
            u.setIdInstalacion(b.getIdInstalacion());
            u.setNombre(b.getNombre());
            us.update(u,"Instalacion");
            return 1;
            }catch(Exception e){
            return 0;
                }
	}
	public static int eliminarInstalacion(Instalacion b){
		DAO us = new DAO();
		try{
            us.delete("Instalacion", b.getIdInstalacion());
            return 1;
                }catch(Exception e){
            return 0;
                }
	}
        
	}


